//
//  YZUserTextFieldView.m
//  实战项目之登录
//
//  Created by Liu on 16/5/10.
//  Copyright © 2016年 Liu. All rights reserved.
//

#import "YZUserTextFieldView.h"

@interface YZUserTextFieldView ()

/**
 *  左边的图片view
 */
@property (nonatomic , strong)UIImageView *leftImageView;


@end


@implementation YZUserTextFieldView

//改变文字位置
-(CGRect) textRectForBounds:(CGRect)bounds{
    CGRect iconRect=[super textRectForBounds:bounds];
    iconRect.origin.x+=10;
    return iconRect;
}
//改变编辑时文字位置
-(CGRect) editingRectForBounds:(CGRect)bounds{
    CGRect iconRect=[super editingRectForBounds:bounds];
    iconRect.origin.x+=10;
    return iconRect;
}

//改变leftView的bounds
-(CGRect)leftViewRectForBounds:(CGRect)bounds {
    bounds = CGRectMake(10, 5, 20, 20);
    return bounds;
}

-(void)awakeFromNib {
    self.leftView = self.leftImageView;
    self.leftViewMode = UITextFieldViewModeAlways;

}



#pragma mark - 懒加载
-(UIImageView *)leftImageView {
        if (_leftImageView == nil) {
            _leftImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"product_img_icon_xieyi.png"]];
            _leftImageView.frame = CGRectMake(0, 0, 20, 20);
            _leftImageView.contentMode = UIViewContentModeScaleAspectFit;
        }
        return _leftImageView;
}


@end
